#ifndef __DBSERVERSENDER_H__
#define __DBSERVERSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../NetMessage.h"
#include "dbserver.pb.h"

/**
*@file       DBServerSender.h
*@brief      send message DBServer
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/16
*/

///message wrapper
class msgDBServer
{
public:
    static const int MessageId = DBServer;
    //TODO
    pnSessionHandle SessionId;
    DBServerMain    MainMsg;

    msgDBServer(int session_id, int sub_id, const std::string& buffer):
    SessionId(session_id)
    {
        MainMsg.set_subid(sub_id);
        MainMsg.set_subbuffer(buffer);
    }
};

class HandleDBServer
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of DBServer
    ///retval     void
    static void HandleMessage(msgDBServer* msg)
    {
        //TODO
        ProtoNet<DBServerMain>::Send(msg->SessionId, msgDBServer::MessageId, msg->MainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgDBServer, HandleDBServer);

#endif
